<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__dept">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-select v-model="dataForm.linkType" placeholder="请选择扫码票类型" clearable>
            <el-option label="门票" :value="1">
            </el-option>
            <el-option label="船票" :value="2">
            </el-option>
            <el-option label="渔家乐" :value="3">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="">
          <el-input v-model="dataForm.scanName" placeholder="扫码票名称"></el-input>
        </el-form-item>
        <el-form-item label="">
          <el-input v-model="dataForm.scanDevice" placeholder="扫码设备名称"></el-input>
        </el-form-item>
        <!-- <el-form-item label="">
          <el-input v-model="dataForm.userAge" placeholder="年龄"></el-input>
        </el-form-item> -->
        <el-form-item>
          <el-button @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('ocp:dm:save')" type="primary" @click="addOrUpdateHandle()">{{
            $t("add") }}</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle"
        @sort-change="dataListSortChangeHandle" style="width: 100%">
        <el-table-column prop="name" label="设备名称" align="center" min-width="150"></el-table-column>
        <el-table-column prop="en" label="设备序列号" align="center" min-width="150"></el-table-column>
        <el-table-column prop="type" label="设备类型" align="center" width="150px">
          <template slot-scope="scope">
            {{ scope.row.type == 1 ? '手持扫描枪' : '闸机' }}
          </template>
        </el-table-column>
        <el-table-column prop="linkType" label="关联的类型" align="center" width="150px">
          <template slot-scope="scope">
            {{ scope.row.linkType == 1 ? '景区门票' : scope.row.linkType == 2 ? '船票' : '渔家乐' }}
          </template>
        </el-table-column>
        <el-table-column prop="linkName" label="关联的类型名称" align="center" min-width="150">
        </el-table-column>
        <el-table-column prop="location" label="设备安放区域" min-width="120px" align="center"></el-table-column>
        <el-table-column prop="status" label="状态" align="center" width="150px">
          <template slot-scope="scope">
            {{ scope.row.status == 1 ? '授权' : '未授权' }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <el-button v-if="$hasPermission('ocp:dm:update')" type="text" size="small"
              @click="addOrUpdateHandle(scope.row.id)">{{ $t("update") }}</el-button>
            <el-button v-if="$hasPermission('ocp:dm:delete')" type="text" size="small"
              @click="deleteHandle(scope.row.id)">{{ $t("delete") }}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
        layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from "@/mixins/view-module";
import AddOrUpdate from "./device-add-or-update";
export default {
    mixins: [mixinViewModule],
    data() {
        return {
            mixinViewModuleOptions: {
                getDataListURL: "/order/dm/page",
                getDataListIsPage: true,
                deleteIsBatch:true,
                deleteURL: "/order/dm",
            },
            dataForm: {
                linkType: '',
                status: '',
                type: '',
            },
        };
    },
    components: {
        AddOrUpdate
    },
    methods: {}
};
</script>
